import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "@/layout";

export const constantRoutes = [
  {
    path: "/",
    redirect: "/home1",
    component: () => import("@/views/dashboard/index"),
  },
  {
    path: "/login",
   // redirect: "/dashboard",
    component: () => import("@/views/login/index"),
    hidden: true,
  },

  {
    path: "/404",
    component: () => import("@/views/404"),
    hidden: true,
  },

  // {
  //   path: "/dashboard",
  //   component: Layout,
  //   redirect: "/dashboard",
  //   hidden:true,
  //   children: [
  //     {
  //       path: "dashboard",
  //       name: "Dashboard",
  //       component: () => import("@/views/dashboard/index"),
  //       meta: { title: "首页", icon: "dashboard" },
  //     },
  //   ],
  // },

  {
    path: '/login2',
    name: 'Login2',
    component: () => import('@/views/login/Login2.vue')
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('@/views/login/Register.vue')
  },
  {
    path: '/password',
    name: 'Password',
    component: () => import('@/views/login/Password.vue')
  },
  {
    path: '/retrieve',
    name: 'Retrieve',
    component: () => import('@/views/login/Retrieve.vue')
  },
  {
    path: '/home1',
    name: 'Home1',
    component: () => import('@/views/Home/Home1.vue')
  },
  {
    path: '/home2/:param/:param1',
    name: 'Home2',
    component: () => import('@/views/Home/Home2.vue')
  },
  {
    path: '/training/:staName/:pjName/:pjId/:staId',
    name: 'Training',
    component: () => import('@/views/training/training.vue')
  },
  {
    path: '/assessment/:staName/:pjName/:pjId/:staId/:sId',
    name: 'Assessment',
    component: () => import('@/views/assessment/assessment.vue')
  },

{
    path: "/person",
    component: Layout,
    children: [
      {
        path: "",
        name: "person",
        component: () => import("@/views/person/person.vue"),
        meta: { title: "个人主页", icon: "nested", breadcrumb: true},
      },
    ],
  },

  {
    path: "/message",
    component: Layout,
    children: [
      {
        path: "",
        name: "Message",
        component: () => import('@/views/message/message.vue'),
        meta: { title: "留言管理", icon: "form" },
      },
    ],
  },



  {
    path: "/certificate",
    component: Layout,
    children: [
      {
        path: "certificate",
        name: "certificate",
        component: () => import("@/views/certificate/certificate"),
        meta: { title: "我的证书", icon: "form" },
      },
    ],
  },

  {
    path: "/application",
    component: Layout,
    name: "application",
    redirect: '/application/training-records',
    meta: {
      title: "我的申请",
      icon: "nested",
    },
    children: [
      {
        path: "training-records",
        component: () => import("@/views/application/training-records.vue"),
        name: "training-records",
        meta: { title: "培训记录" },
      },
      {
        path: "application-records",
        component: () => import("@/views/application/application-records.vue"),
        name: "application-records",
        meta: { title: "对比测试申请记录" },
      },
    ],
  },

  {
    path: "/Account-manage",
    component: Layout,
    name: "account-manage",
    hidden: true,
    meta: {
      title: "账户管理",
      icon: "user"
    },
    children: [
      {
        path: "modify-personal",
        component: () => import("@/views/Account-manage/modify-personal.vue"),
        name: "modify-personal",
        meta: { title: "人员信息修改"},
      },
      {
        path: "modify-password",
        component: () => import("@/views/Account-manage/modify-password.vue"),
        name: "modify-password",
        meta: { title: "修改密码"},
      },
    ],
  },

  {
    path: '/module/:pjId/:staName/:pjName/:staId',
    component: () => import('@/views/module-select/module.vue'),
    name: 'module',
  },

  {
    path: '/sample',
    component: () => import('@/views/List/sample.vue'),
    name: 'sample',
  },

  {
    path: '/device/:staName/:pjName/:pjId/:staId',
    component: () => import('@/views/Device/device.vue'),
    name: 'device',
  },
  {
    path: '/device-scheme/:staName/:pjName/:staId/:pjId/:eId/:eName',
    component: () => import('@/views/Device-scheme/device-scheme.vue'),
    name: 'device-scheme',
  },
  {
    path: '/sample2/:staId/:staName',
    component: () => import('@/views/sample/sample.vue'),
    name: 'sample2',
  },
  {
    path: '/regulation/:staName/:pjName/:pjId/:staId',
    component: () => import('@/views/regulation/regulation.vue'),
    name: 'regulation',
  },


  // {
  //   path: '/people',
  //   component: Layout,
  //   redirect: 'people',
  //   name: '人员界面',
  //   hidden:true,
  //   meta: {
  //     title: '人员界面',
  //     icon: 'nested'
  //   },
  //   children: [
  //     {
  //       path: 'people',
  //       name: '人员界面',
  //       component: () => import('@/views/people/people.vue'),
  //       meta: { title: '人员界面', icon: 'nested' }
  //     },
  //     {
  //       path: 'train',
  //       component: () => import('@/views/people/train_manage/train.vue'),
  //       name: 'train',
  //       meta: { title: '培训管理' },

  //     },
  //     {
  //       path: 'leave-words',
  //       component: () => import('@/views/people/train_manage/leave-words.vue'),
  //       name: 'leave-words',
  //       meta: { title: '留言管理' }
  //     },

  //     {
  //       path: 'audit',
  //       component: () => import('@/views/people/train_manage/audit.vue'),
  //       name: 'audit',
  //       meta: { title: '授权审核' }
  //     },

  //     {
  //       path: 'certificate',
  //       component: () => import('@/views/people/train_manage/certificate.vue'),
  //       name: 'certificate',
  //       meta: { title: '证书界面' }
  //     },
  //   ]
  // },


  // 404 page must be placed at the end !!!
  { path: "*", redirect: "/404", hidden: true },
];

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes,
  });

const router = createRouter();

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
